﻿using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FlexField.Metadata.EntityFrameworkCore;
using FlexField.Metadata.TestHarness;
using Microsoft.Extensions.DependencyInjection;

namespace FlexField.Metadata.EFCore.Tests
{
    public abstract class EFCoreStoreTestBase : MetadataManagerTestBase
    {
        protected abstract DbConnection GetConnection();

        protected override object CreateDbContext()
            => TestDbContext.Create(GetConnection());

        protected override void AddTypeSore(MetadataBuilder builder, object context = null)
        {
            var store = new DataEntityStore<TestDbContext,Guid>((TestDbContext)context, new UpperInvariantLookupNormalizer(), Errors);
            builder.Services.AddSingleton<IEntityStore<Guid>>(store);
        }

        protected override void AddFieldStore(MetadataBuilder builder, object context = null)
        {
            var store = new DataFieldStore<TestDbContext, Guid>((TestDbContext)context, new UpperInvariantLookupNormalizer(), Errors);
            builder.Services.AddSingleton<IFieldStore<Guid>>(store);
        }
    }
}
